/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.grnt.common;

/**
 *
 * It is a travelor template. When a travelor object doing, it will call Function's
 * entity method doWith(element);
 * @param <TRoot> A collection's root type.
 * @param <TElement> It is the type will give to Function.
 * @author sayid
 */
public interface Travelor <TRoot, TElement>{
	/**
	 * It is a Exception class thrown by Travelor.
	 */
	public static class TravelException extends Exception {

		public TravelException(Throwable arg0) {
			super(arg0);
		}

		public TravelException(String arg0, Throwable arg1) {
			super(arg0, arg1);
		}

		public TravelException(String arg0) {
			super(arg0);
		}

		public TravelException() {
		}
	}

	/**
	 *
	 * Reset the value of root field
	 * @param root Input value.
	 * @return if correct return true;
	 */

	public boolean setRoot(TRoot root);
	/**
	 *
	 * To check this object is wellform.
	 * @return If it is wellform return true.
	 */
	public boolean isActive();
	/**
	 *
	 * The algorithm implements travel action.
	 * @param doElement
	 */
	public void travel(Function<TElement, ?> doElement);
}
